package ru.netcracker.jcl.command;

import java.io.IOException;
import java.io.PrintStream;
import java.util.List;
import java.util.Scanner;


public class EchoCommand extends AbstractCommand implements ICommand {

	public void run() throws IOException {
		run(null);
	}

	public void run(List<String> args) throws IOException {
		PrintStream printStream = new PrintStream(super.getOutputStream());
		if (super.getInputStream() != null) {
			Scanner scanner = new Scanner(super.getInputStream());
			while (scanner.hasNext()) {
				printStream.println(scanner.nextLine());
			}
		}
		if (args != null) {
			for (String arg : args) {
				printStream.print(arg + " ");
			}
		}

	}

}
